home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_glimpse.idb / usr / freeware / src / glimpse-3.0 / libtemplate / template / print-template.c.z / print-template.c
C/C++ Source or Header  |  1997-09-09  |  3KB  |  87 lines

  1. static char rcsid[] = "$Id: print-template.c,v 1.9 1995/01/10 16:30:38 hardy Exp $";
  2. /*
  3.  *  print-template - Reads in a template from stdin and prints it to stdout.
  4.  *  Used to test template parsing and printing.
  5.  *
  6.  *  Darren Hardy, hardy@cs.colorado.edu, February 1994
  7.  *
  8.  *  ----------------------------------------------------------------------
  9.  *  Copyright (c) 1994, 1995.  All rights reserved.
  10.  *  
  11.  *          Mic Bowman of Transarc Corporation.
  12.  *          Peter Danzig of the University of Southern California.
  13.  *          Darren R. Hardy of the University of Colorado at Boulder.
  14.  *          Udi Manber of the University of Arizona.
  15.  *          Michael F. Schwartz of the University of Colorado at Boulder. 
  16.  *  
  17.  *  This copyright notice applies to all code in Harvest other than
  18.  *  subsystems developed elsewhere, which contain other copyright notices
  19.  *  in their source text.
  20.  *  
  21.  *  The Harvest software was developed by the Internet Research Task
  22.  *  Force Research Group on Resource Discovery (IRTF-RD).  The Harvest
  23.  *  software may be used for academic, research, government, and internal
  24.  *  business purposes without charge.  If you wish to sell or distribute
  25.  *  the Harvest software to commercial clients or partners, you must
  26.  *  license the software.  See
  27.  *  http://harvest.cs.colorado.edu/harvest/copyright,licensing.html#licensing.
  28.  *  
  29.  *  The Harvest software is provided ``as is'', without express or
  30.  *  implied warranty, and with no support nor obligation to assist in its
  31.  *  use, correction, modification or enhancement.  We assume no liability
  32.  *  with respect to the infringement of copyrights, trade secrets, or any
  33.  *  patents, and are not responsible for consequential damages.  Proper
  34.  *  use of the Harvest software is entirely the responsibility of the user.
  35.  *  
  36.  *  For those who are using Harvest for non-commercial purposes, you may
  37.  *  make derivative works, subject to the following constraints:
  38.  *  
  39.  *  - You must include the above copyright notice and these accompanying 
  40.  *    paragraphs in all forms of derivative works, and any documentation 
  41.  *    and other materials related to such distribution and use acknowledge 
  42.  *    that the software was developed at the above institutions.
  43.  *  
  44.  *  - You must notify IRTF-RD regarding your distribution of the 
  45.  *    derivative work.
  46.  *  
  47.  *  - You must clearly notify users that your are distributing a modified 
  48.  *    version and not the original Harvest software.
  49.  *  
  50.  *  - Any derivative product is also subject to the restrictions of the 
  51.  *    copyright, including distribution and use limitations.
  52.  */
  53. #include <stdio.h>
  54. #include <string.h>
  55. #include <time.h>
  56. #include "util.h"
  57. #include "template.h"
  58.  
  59. static void add_print_time(t)
  60. Template *t;
  61. {
  62.     char buf[BUFSIZ];
  63.  
  64.     sprintf(buf, "%u", (unsigned int) time(NULL));
  65.     add_AVList(t->list, "Print-Time", buf, strlen(buf));
  66. }
  67.  
  68. int main(argc, argv)
  69. int argc;
  70. char *argv[];
  71. {
  72.     Template *template;
  73.     Buffer *b;
  74.  
  75.     init_parse_template_file(stdin);    /* Read Template from stdin */
  76.     while ((template = parse_template()) != NULL) {
  77.         add_print_time(template);    /* Add new Attribute-Value */
  78.         b = init_print_template(NULL);    /* Print Template to Buffer */
  79.         print_template(template);    
  80.         fwrite(b->data, 1, b->length, stdout);    /* Buffer to stdout */
  81.         finish_print_template();    /* Clean up */
  82.         free_template(template);    
  83.     }
  84.     finish_parse_template();
  85.     exit(0);
  86. }
  87.